<?php

/**
 * Rubros filter form.
 *
 * @package    tercermilenio
 * @subpackage filter
 * @author     Your name here
 */
class RubrosFormFilter extends BaseRubrosFormFilter {

    public function configure() {

    }

    public function setup() {
        parent::setup();

        $this->setWidgets(array(
            'rub_nombre' => new sfWidgetFormFilterInput(array('with_empty' => false)),
        ));

        $this->setValidators(array(
            'rub_nombre' => new sfValidatorSchemaFilter('text',new sfValidatorString(array('required' => false))),
        ));

        $this->widgetSchema->setNameFormat('rubros_filters[%s]');
        $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
    }

    public function addRubNombreColumnCriteria(Criteria $criteria, $field, $values) {
        if(!empty($values['text'])){
            $column = $this->getColName($field);
            $criteria->add(RubrosPeer::RUB_NOMBRE, $values['text'].'%',Criteria::LIKE);
        }
    }

}
